﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using blackhouse.BlackApart.Data;
using System.Drawing;

namespace blackhouse.BlackApart.Business.Apartments {
	public class ImpApartmentPhoto : IApartmentPhoto, IComparer<IApartmentPhoto> {

		#region Fields

		private IApartmentPhoto[] photos;
		private int apartmentId;
		private int apartmentTypeId;

		#endregion

		#region Properties

		public int PhotoId { get; set; }
		public string PhotoName { get; set; }
		public string Category { get; set; }
		public string Description { get; set; }
		public int Sort { get; set; }

		#endregion

		#region Methods

		public void Read(ApartmentPhotoData apartmentPhotoData) {
			DaApartmentPhoto.SetImp(this, apartmentPhotoData);
		}

		public void SetApartmentPhotos(int apartmentId, IApartmentPhoto[] photos) {
			Array.Sort(photos, new ImpApartmentPhoto());
			this.photos = photos;
			this.apartmentId = apartmentId;
		}

		public void SetApartmentTypePhotos(int apartmentTypeId, IApartmentPhoto[] photos) {
			Array.Sort(photos, new ImpApartmentPhoto());
			this.photos = photos;
			this.apartmentTypeId = apartmentTypeId;
		}

		public IApartmentPhoto[] GetApartmentPhotos(int apartmentId) {
			if (apartmentId == this.apartmentId)
				return photos;
			else return new IApartmentPhoto[0];
		}

		public IApartmentPhoto[] GetApartmentTypePhotos(int apartmentTypeId) {
			if (apartmentTypeId == this.apartmentTypeId)
				return photos;
			else return new IApartmentPhoto[0];
		}

        public int Compare(IApartmentPhoto x, IApartmentPhoto y) {
            return x.Sort.CompareTo(y.Sort);
        }

        public string GetImageUrl(Size size) {
            return String.Empty;
        }

		#endregion

    }
}
